/**
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
 */

#include <linux/module.h>

#include "dvpp_cmdlist_proc.h"
#include "dvpp_cmdlist_context.h"
#include "dvpp_sqe_update.h"
#include "dvpp_cmdlist.h"
#include "vpc_cmdlist.h"
#include "jpegd_cmdlist.h"
#include "jpege_cmdlist.h"
#include "dvpp_tlv_decoder.h"
#include "dvpp_vpu_decoder.h"
#include "dvpp_mem_allocater.h"
#include "dvpp_cmdlist_ioctl.h"
#include "dvpp_vmng.h"

#ifdef SUPPORT_VIR_MACH
#include "dvpp_share_mem_ctrl.h"
#endif

#include "dvpp_vpc_pipe.h"

static int32_t __init dvpp_cmdlist_init(void)
{
    // 注册三个模块的cmdlist引擎
    jpege_cmdlist_engine_register();
    jpegd_cmdlist_engine_register();
    vpc_cmdlist_engine_register();

    // 注册两种解码器用于解析args
    dvpp_tlv_decoder_register();
    dvpp_vpu_decoder_register();

#ifdef RUN_MODE_OFFLINE
    // 注册vpc pipe用户配置vpu_config
    dvpp_vpc_pipe_init_export_func();
#endif

    dvpp_sqe_update_init();

    dvpp_cmdlist_context_init();
    dvpp_cmdlist_init_proc();

#ifdef SUPPORT_VIR_MACH
    // 注册虚拟机上线通知，rc形态 不支持虚拟机
    (void)dvpp_vmng_init();
    spin_lock_init(&g_share_mem_pool_lock);
#endif

    dvpp_cmdlist_dev_init();
    return 0;
}

static void __exit dvpp_cmdlist_exit(void)
{
    dvpp_cmdlist_dev_exit();
#ifdef SUPPORT_VIR_MACH
    (void)dvpp_vmng_uninit();
#endif
    dvpp_cmdlist_remove_proc();
    dvpp_cmdlist_context_deinit();
    dvpp_sqe_update_uninit();
#ifdef RUN_MODE_OFFLINE
    dvpp_vpc_pipe_uninit_export_func();
#endif
    dvpp_vpu_decoder_unregister();
    dvpp_tlv_decoder_unregister();
    vpc_cmdlist_engine_unregister();
    jpegd_cmdlist_engine_unregister();
    jpege_cmdlist_engine_unregister();
    dvpp_deinit_mem_allocater();
    return;
}

module_init(dvpp_cmdlist_init);
module_exit(dvpp_cmdlist_exit);

MODULE_LICENSE("GPL");

